<?php

namespace Zch\LishangLaravelShop\Wap\Shop\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Route;

class ShopServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->registerRoutes();
        $this->registerPublishing();
    }

    public function boot()
    {
        $this->loadViewsFrom(
            __DIR__ . '/../Resources/views/', 'wap.shop'
        );
    }

    private function routeConfiguration(){
        return [
            'namespace' => 'Zch\LishangLaravelShop\Wap\Shop\Http\Controllers',
            'prefix' => 'wap/shop',
            'middleware' => 'web'
        ];
    }

    public function registerRoutes()
    {
        Route::group($this->routeConfiguration(),function(){
            $this->loadRoutesFrom(__DIR__ . '/../Routes/shopRoutes.php');
        });
    }

    public function registerPublishing()
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
               __DIR__ . '/../Resources/assets/' => public_path('vendor/zch/lishang-wap-shop')
            ], 'lishang-wap-shop');
        }
    }
}
